<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增展会区域')" />
</head>
<body>
<div class="main-content">
    <form id="form-eventRoster-add" class="form-horizontal">
        <input name="deptId" type="hidden" id="treeId"/>
        <h4 class="form-header h4">基本信息</h4>
        <div class="row">
            <div class="col-sm-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">展会名称：</label>
                    <div class="col-sm-8">
                        <select id="rosterId" name="rosterId" class="form-control m-b">
                            <option th:each="post:${eventRoster}" th:value="${post.rosterId}" th:text="${post.eventName}"></option>
                        </select>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">区域编号：</label>
                    <div class="col-sm-8">
                        <input class="form-control" type="text" name="areaNum" id="areaNum" required>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">摊位编号：</label>
                    <div class="col-sm-8">
                        <input class="form-control" type="text" name="boothNum" id="boothNum" required>
                    </div>
                </div>
            </div>
        </div>
    </form>
</div>

<th:block th:include="include :: footer" />
<script>
    var prefix = ctx + "system/eventRegion";

    // $("#form-eventRoster-add").validate({
    //     onkeyup: false,
    //     rules:{
    //     },
    //     focusCleanup: true
    // });

    $('input').on('ifChanged', function(obj){
        var type = $(this).val();
        var checked = obj.currentTarget.checked;
        if (type == 1) {
            if (checked) {
                $._tree.expandAll(true);
            } else {
                $._tree.expandAll(false);
            }
        } else if (type == "2") {
            if (checked) {
                $._tree.checkAllNodes(true);
            } else {
                $._tree.checkAllNodes(false);
            }
        } else if (type == "3") {
            if (checked) {
                $._tree.setting.check.chkboxType = { "Y": "ps", "N": "ps" };
            } else {
                $._tree.setting.check.chkboxType = { "Y": "", "N": "" };
            }
        }
    })

    function submitHandler() {
        if ($.validate.form()) {
            add();
        }
    }

    function add() {
        // var myselect=document.getElementById("sortId");
        var rosterId = document.getElementById("rosterId").value;
        var areaNum = document.getElementById("areaNum").value;
        var boothNum = document.getElementById("boothNum").value;
        // var startTime = document.getElementById("startTime").value;
        // var endTime = document.getElementById("endTime").value;
        $.ajax({
            cache : true,
            type : "POST",
            url : prefix + "/add",
            data : {
                "rosterId": rosterId,
                "areaNum": areaNum,
                "boothNum": boothNum
            },
            async : false,
            error : function(request) {
                $.modal.alertError("系统错误");
            },
            success : function(data) {
                $.operate.successCallback(data);
            }
        });
    }

    // function submitHandler() {
    //     var chrtype = [[${#strings.defaultString(@config.getKey('sys.account.chrtype'), 0)}]];
    //     var password = $("#password").val();
    //     if ($.validate.form() && checkpwd(chrtype, password)) {
    //         var data = $("#form-eventRoster-add").serializeArray();
    //         var status = $("input[id='status']").is(':checked') == true ? 0 : 1;
    //         var roleIds = $.form.selectCheckeds("role");
    //         var postIds = $.form.selectSelects("post");
    //         data.push({"name": "status", "value": status});
    //         data.push({"name": "roleIds", "value": roleIds});
    //         data.push({"name": "postIds", "value": postIds});
    //         $.operate.saveTab(prefix + "/add", data);
    //     }
    // }

</script>
</body>
</html>